// 取面对象 中心点
export function getCenter(PolygonArr) {
  let total = PolygonArr.length;
  let X = 0;
  let Y = 0;
  let Z = 0;
  PolygonArr.forEach(lnglat => {
    let lng = (lnglat[0] * Math.PI) / 180;
    let lat = (lnglat[1] * Math.PI) / 180;
    let x, y, z;
    x = Math.cos(lat) * Math.cos(lng);
    y = Math.cos(lat) * Math.sin(lng);
    z = Math.sin(lat);
    X += x;
    Y += y;
    Z += z;
  });
  X = X / total;
  Y = Y / total;
  Z = Z / total;

  let Lng = Math.atan2(Y, X);
  let Hyp = Math.sqrt(X * X + Y * Y);
  let Lat = Math.atan2(Z, Hyp);
  console.log(Lng, Lat, Hyp);
  return [(Lng * 180) / Math.PI, (Lat * 180) / Math.PI];
}
